home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ADA Programming Guide
/
ADA Programming Guide.iso
/
ada_gnu
/
adainc
/
a-nuflra.adb
< prev
next >
Wrap
Text File
|
1996-01-30
|
4KB
|
105 lines
------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- A D A . N U M E R I C S . F L O A T _ R A N D O M --
-- --
-- B o d y --
-- --
-- $Revision: 1.10 $ --
-- --
-- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved --
-- --
-- The GNAT library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU Library General Public License as published by --
-- the Free Software Foundation; either version 2, or (at your option) any --
-- later version. The GNAT library is distributed in the hope that it will --
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Library General Public License for more details. You should have --
-- received a copy of the GNU Library General Public License along with --
-- the GNAT library; see the file COPYING.LIB. If not, write to the Free --
-- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
-- This implementation is derived from LSN 1055 written by Ken Dritz.
with Ada.Calendar;
with Unchecked_Deallocation;
package body Ada.Numerics.Float_Random is
--------------
-- Finalize --
--------------
procedure Finalize (Gen : in out Generator) is
procedure Destroy_State is
new Unchecked_Deallocation (ANR.State, Access_State);
begin
Destroy_State (Gen.State);
end Finalize;
-----------
-- Image --
-----------
function Image (Of_State : State) return String is
begin
return ANR.Image (ANR.State (Of_State));
end Image;
------------
-- Random --
------------
function Random (Gen : Generator) return Uniformly_Distributed is
U : Float;
begin
ANR.Random (Gen.State.all, U);
return U;
end Random;
-----------
-- Reset --
-----------
procedure Reset (Gen : in Generator; Initiator : in Integer) is
begin
ANR.Reset (Gen.State.all, Initiator);
end Reset;
procedure Reset (Gen : in Generator) is
begin
ANR.Reset (Gen.State.all);
end Reset;
procedure Reset (Gen : in Generator; From_State : in State) is
begin
Gen.State.all := ANR.State (From_State);
end Reset;
----------
-- Save --
----------
procedure Save (Gen : in Generator; To_State : out State) is
begin
To_State := State (Gen.State.all);
end Save;
-----------
-- Value --
-----------
function Value (Coded_State : String) return State is
begin
return State (ANR.Value (Coded_State));
end Value;
end Ada.Numerics.Float_Random;